package com.acme.bankapp.service.bank.network.command;

import com.acme.bankapp.domain.bank.Bank;
import com.acme.bankapp.domain.bank.client.Client;

/**
 * This class implements {@link Command} interface for command to print balance of all clients
 *
 * @author Alexander Kotov (kotov.alex.22@gmail.com)
 */
public class PrintBalanceCommand implements Command {
    /**
     * {@inheritDoc}
     */

    private Bank bank;

    public PrintBalanceCommand(final Bank bank) {
        this.bank = bank;
    }

    @Override
    public String execute() {
        String result = String.format("Clients: ");
        for (Client client: bank.getClients()) {
            result += String.format("%s %s; ", client, client.getAccount());
        }
        return result;
    }
}
